package com.example.tliasmanagement.service.impl;

import com.example.tliasmanagement.dto.QuerySubjectDTO;
import com.example.tliasmanagement.dto.SubjectListDto;
import com.example.tliasmanagement.entity.Subject;
import com.example.tliasmanagement.mapper.SubjectMapper;
import com.example.tliasmanagement.service.SubjectService;
import com.example.tliasmanagement.vo.EmpListVo;
import com.example.tliasmanagement.vo.PageBean;
import com.example.tliasmanagement.vo.SubjectVo;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SubjectServiceImpl implements SubjectService {
    @Autowired
    private SubjectMapper subjectMapper;

    @Override
    public PageBean<SubjectVo> subs(QuerySubjectDTO dto){
        // 1.开启分页
        PageHelper.startPage(dto.getPage(), dto.getPageSize());
        // 2. 当前页的列表查询
        Page<SubjectVo> page = subjectMapper.page(dto);
        //3. 组合，封装返回
        return new PageBean(page.getTotal(), page.getResult());
    }
}
